<html>

<head>
<meta charset="UTF-8">
<title>用户管理</title>
</head>
<body>
	<#import "/page.ftl" as page />
	<link rel="stylesheet" type="text/css" href="/css/form.css">
	<script type="text/javascript" src="/js/user_manage.js"></script>
	<#include "/head.ftl"/>
	<div class="content">
		<div class="tab">
			<div class="tab-header">
				<a href="/user/user/add" title="添加用户" class="btn btn-setting btn-add" id="add"> <i class="iconfont icon-add"
					style="font-size: 16px;"></i>
				</a>
				<a title="刷新" class="btn btn-setting" onclick="refresh(this)">
					<i class="iconfont icon-refresh"></i>
				</a>
				<!-- <a title="查看生日" class="btn btn-setting" >
					<i class="iconfont icon-cake"></i>
				</a> -->
				<div class="tab-tool">
					<select name="dept">
						<option value="">所有部门</option>
						<#list depts as d>
							<#if RequestParameters.deptId?? && RequestParameters.deptId!="" && RequestParameters.deptId?number==d.id>
								<option value="${d.id}" selected="selected">${d.name}</option>
							<#else>
								<option value="${d.id}">${d.name}</option>
							</#if>
						</#list>
					</select>
					<input name="key" type="text" placeholder="按名称或电话查找...">
					<a onclick="userSearch()" class="search-btn">
						<i class="iconfont icon-search"></i>
					</a>
				</div>
			</div>
			<div class="tab-content">
				<div>
					<#assign sort=users.sort?replace(': ',',') />
					<table style="width: 100%; border-collapse: collapse;">
						<tr>
							<th>性别
								<#if sort=='sex,DESC'>
									<a onclick="pageSort('${requestURI}','sex')"><i class="iconfont icon-arrowdown"></i></a>
								<#elseif sort=='sex,ASC' >
									<a  onclick="pageSort('${requestURI}','sex,desc')"><i class="iconfont icon-arrowup"></i></a>
								<#else>
									<a onclick="pageSort('${requestURI}','sex')"><i class="iconfont icon-arrowdown"></i></a>
								</#if>
							</th>
							<th>部门</th>
							<th>职位</th>
							<th>真实姓名</th>
							<th>基本工资
								<#if sort=='sal,DESC'>
									<a onclick="pageSort('${requestURI}','sal')"><i class="iconfont icon-arrowdown"></i></a>
								<#elseif sort=='sal,ASC' >
									<a  onclick="pageSort('${requestURI}','sal,desc')"><i class="iconfont icon-arrowup"></i></a>
								<#else>
									<a onclick="pageSort('${requestURI}','sal')"><i class="iconfont icon-arrowdown"></i></a>
								</#if>
							</th>
							<th>联系方式</th>
							<th>角色</th>
							<th>入职时间
								<#if sort=='hiredate,DESC'>
									<a href="${requestURI}&sort=hiredate"><i class="iconfont icon-arrowdown"></i></a>
								<#elseif sort=='hiredate,ASC' >
									<a href="${requestURI}&sort=hiredate,desc"><i class="iconfont icon-arrowup"></i></a>
								<#else>
									<a href="${requestURI}&sort=hiredate"><i class="iconfont icon-arrowdown"></i></a>
								</#if>
							</th>
							<th width="25%">操作</th>
						</tr>
						<#list (users.content) as users>
							<tr>
								<td>
									<#if users.sex=='女'>
										<i class="iconfont icon-girl"></i>
									<#else>
										<i class="iconfont icon-boy"></i>
									</#if>
								</td>
								<td>${users.dept.name}</td>
								<td>${users.deptOffice.name}</td>
								<td>${users.realName}</td>
								<td>${users.sal}</td>
								<td>${users.tel}</td>
								<td>
									<!-- 要将懒加载关闭才能获取到 -->
									<#if  (users.roles)?exists>
										<#list users.roles as role>
											${role.name}<br>
										</#list>
									</#if>
								</td>
								<td>${users.hiredate}</td>
								<td>
									<a href="/user/user/info?id=${users.id}" title="查看详情" class="btn btn-look"><i class="iconfont icon-search"></i><span> 查看详情</span></a>
									<a class="btn btn-up" onclick="accountSet(this)"><i class="iconfont icon-setup"></i><span> 账号管理</span></a>
									<div class="account" style="display: none;padding: 10px 20px;">
										<h4 style="padding:10px;"><font color="#aa0000">${users.realName}</font>的帐号设置</h4>
										<div>
											<input type="hidden" name="userId" value="${users.id}">
											账号：<input type="text" name="accountName" value="${users.name}" style="padding-right: 20px;margin-bottom:10px;">
											<div class="hidePwd pwd">
												密码：<input type="password" name="accountPwd" placeholder="密码长度在6-12位之间" onkeyup="copyPwd(this)" maxlength="20" value="${users.password}">
												<a class="eye" onclick="changeEye(this)"><i class="iconfont icon-eye"></i></a>
											</div>
											<div class="showPwd pwd">
												密码：<input type="text" name="passwordText" placeholder="密码长度在6-12位之间" onkeyup="copyPwd(this)" maxlength="20" value="${users.password}">
												<a class="eye" onclick="changeEye(this)"><i class="iconfont icon-eye-close"></i></a>
											</div>
										</div>
									</div>
									<a href="/user/user/add?id=${users.id}" title="修改用户" class="btn btn-update"><i class="iconfont icon-brush"></i><span> 修改</span></a>
									<a class="btn btn-delete" onclick="deleteOne(${users.id},'/user/user/delete')"><i class="iconfont icon-trash"></i><span> 删除</span></a>
								</td>
							</tr>
						</#list>
						
					</table>
				</div>
			</div>
			<@page.page url=requestURI pager=users/>
		</div>
	</div>
</body>
</html>